DAYTIME_PORT = 13
PACKET_SIZE = 100

String host = "localhost"
def servAddr = InetAddress.getByName(host)
def sock = new DatagramSocket()

byte[] buffer = new byte[PACKET_SIZE]
def packet = new DatagramPacket(buffer, PACKET_SIZE, servAddr, DAYTIME_PORT)
packet.setLength(PACKET_SIZE-1)
sock.send(packet)
println "Sent request to server ..."

sock.receive(packet)
println "Got packet of size ${packet.getLength()}"
println "Date on ${host} is ${new String(buffer, 0, packet.getLength())}"
